//-------------------------------------------------------------------------------
//Vertex and pixel shader demonstrating ambient and diffuse lighting
// Ambient intensity values are pre baked
//------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------
// Global params provided by the app
//------------------------------------------------------------------------------------------------------
float4x4 g_mWorldViewProjection;

sampler TextureSampler =
sampler_state {
    MinFilter = Anisotropic;
    MagFilter = LINEAR;
    MipFilter = LINEAR;
    AddressU = WRAP;
    AddressV = WRAP;
};

//---------------------------------------------------------------------------------------------------------------------------
// Input channel (vertex shader)
//---------------------------------------------------------------------------------------------------------------------------
struct InputVS {
float3 Position :
    POSITION;
float2 TextureUV :
    TEXCOORD;
};

//---------------------------------------------------------------------------------------------------------------------------
// Output channel (vertex shader)
//---------------------------------------------------------------------------------------------------------------------------
struct OutputVS {
float4 Position :
    POSITION;
float2 TextureUV:
    TEXCOORD;
};

//---------------------------------------------------------------------------------------------------------------------------
// Vertex shader
//---------------------------------------------------------------------------------------------------------------------------
OutputVS ParticleShaderVS(InputVS input) {
    //Zero out our output
    OutputVS outVS = (OutputVS)0;

    //Transform to homogeneous clipspace
    outVS.Position = mul(float4(input.Position, 1.0f), g_mWorldViewProjection);
    //normals
    outVS.TextureUV = input.TextureUV;

    //return output
    return outVS;
}

//---------------------------------------------------------------------------------------------------------------------------
// Input channel pixel shader
//---------------------------------------------------------------------------------------------------------------------------
struct InputPS {
float2 TextureUV :
    TEXCOORD;
};

//---------------------------------------------------------------------------------------------------------------------------
// Pixel shader (input channel):output channel
//---------------------------------------------------------------------------------------------------------------------------
float4 ParticleShaderPS(InputPS input): COLOR {
    return tex2D(TextureSampler, input.TextureUV) * 2;
}

technique Particle_Shader {
    pass P0
    {
        Lighting = FALSE;
        SpecularEnable = FALSE;
        FillMode = Solid;
        vertexShader = compile vs_3_0 ParticleShaderVS();
        pixelShader = compile ps_3_0 ParticleShaderPS();
    }
}

technique Particle_Shader_Normal_Alpha {
    pass P0
    {
        Lighting = FALSE;
        SpecularEnable = FALSE;
        FillMode = Solid;
        ZEnable = true;
        ZWriteEnable = true;
        ZFunc = LessEqual;
        AlphaBlendEnable = true;
        SrcBlend = SrcAlpha;
        DestBlend = InvSrcAlpha;
        BlendOp = Add;
        vertexShader = compile vs_3_0 ParticleShaderVS();
        pixelShader = compile ps_3_0 ParticleShaderPS();
    }
}